basepath=$(cd `dirname $0`; pwd)
echo ${basepath}

cd ${basepath}


cd ${basepath}/ColorSpace3rdpart_/zlib-1.2.11

if [ -d ./build_dir ];then
    rm -rf build_dir
fi

mkdir build_dir

cd build_dir

emcmake cmake -DCMAKE_INSTALL_PREFIX=../zlib_install ../ 
emmake make clean
emmake make
emmake make install



cd ${basepath}/ColorSpace3rdpart_/libpng-1.6.37

if [ -d ./build_dir ];then
    rm -rf build_dir
fi

mkdir build_dir

cd build_dir

emcmake cmake -DCMAKE_INSTALL_PREFIX=../libpng_install -DPNG_SHARED=OFF -DPNG_TESTS=OFF -DZLIB_INCLUDE_DIR=${basepath}/ColorSpace3rdpart_/zlib-1.2.11/zlib_install/include -DZLIB_LIBRARY=${basepath}/ColorSpace3rdpart_/zlib-1.2.11/zlib_install/lib ../ 
emmake make clean
emmake make
emmake make install


cd ${basepath}

if [ -d ./Lib ];then
    rm -rf Lib
fi

mkdir Lib

cp -r ColorSpace3rdpart_/zlib-1.2.11/zlib_install Lib/zlib_install
cp -r ColorSpace3rdpart_/libpng-1.6.37/libpng_install Lib/libpng_install
